package com.qabaco.odondata.model.util;

public class Util {
    public Util() {
        super();
    }
    
    public static String obtenerTrace(Exception e){
           if (e == null) return "";
           StringBuffer mensaje = new StringBuffer("");            
           Exception exChequear = e;            
              
           if (e.getCause() != null&&e.getCause().getClass().getName().indexOf("TimedOutException")==-1){
               exChequear = (Exception)e.getCause();
               if (exChequear.getCause() != null){
                   exChequear = (Exception)exChequear.getCause();
               }
           }
                  
           if (exChequear.getMessage() != null)
              mensaje.append(exChequear.getMessage());
           StackTraceElement [] varios = exChequear.getStackTrace();
           mensaje.append(e.getMessage() + "\r\n");
           for (int i = 0; i < varios.length; i++) {
               StackTraceElement stackTraceElement = varios[i];                               
               mensaje.append(stackTraceElement.getClassName() + " - " + stackTraceElement.getMethodName() + " - (" + stackTraceElement.getLineNumber()+ ")" + "\r\n");                
           }     
       return mensaje.toString();    
    }
}
